package chapter5_2;

import com.sun.xml.internal.ws.api.client.WSPortInfo;

public class ForTest {
    public static void main(String[] args) {
     //   test1();
        //   test2();
        test3();

    }

//    public static void test1(){
//        for (int i=0; i<20 ;i++){
//            System.out.println("for循环：i=" +i);
//
//       }
//        System.out.println("for循环结束");
//    }


//    public static void test1(){
//        int i =0;
//        for (; i<20 ;i++){
//            System.out.println("for循环：i=" +i);
//
//        }
//        System.out.println("for循环结束");
//    }

    public static void test1(){
        int i =0;
        for (; i<20 ;){
            System.out.println("for循环：i=" +i);
            i++;
        }
        System.out.println("for循环结束");


    }


    public static void test2(){
        String [] array = {"monkey","dog","pig","bird","tiger"};

        for (String str: array){
            System.out.println("动物类型："+ str);
        }

    }

    public static void test3(){
        String []  array = {"monkey","dog","pig","bird","tiger","fish"};

        for (int i = 0 ; i < array.length ; i++){
            System.out.println("动物类型: " + array[i]);
        }
    }

}
